<?php

/**
 * Class 'tx_mfwcshoolinfos_flexform_flexform' which gets all field names from the "fe_users".
 *
 * @author	Bernhard baumgartl <b.baumgartl@datamints.com>
 * @package	TYPO3
 * @subpackage	tx_mfwcshoolinfos_flexform
 */
class tx_mfwcshoolinfos_flexform {

	/**
	 * The getFields method is used to get the "fe_users" field names into the flexform of the plugin.
	 *
	 * @param	array		$config: The fields selected.
	 * @return	array		$config
	 */
	function getFieldNames($config) {
		// Damit $TCA hier zur Verfuegung steht.
		global $TCA;

		// $TCA-Teil laden. Damit koennen wir alle Felder durchgehen.
		t3lib_div::loadTCA('fe_users');

		$fieldList = array();

		foreach ($TCA['fe_users']['columns'] as $key => $_){
			$fieldList[] = array($key, $key);
		}

		$config['items'] = array_merge($config['items'], $fieldList);

		return $config;
	}
	
	/**
	 * The getFields method is used to get the "fe_users" field names into the flexform of the plugin.
	 *
	 * @param	array		$config: The fields selected.
	 * @return	array		$config
	 */
	function getFieldNames2($config) {
		// Damit $TCA hier zur Verfuegung steht.
		global $TCA;
	//	include(t3lib_extMgm::extPath('mfwc_shoolinfos').'ext_tables.php');
		
		$flexformContent = t3lib_div::xml2array($config['row']['pi_flexform']);
		if(is_array($flexformContent)) {
			$table = $flexformContent['data']['sDEF']['lDEF']['exec_table']['vDEF'];
			
			if($table){
				//debug($table,'$table');
				t3lib_div::loadTCA($table);
				$fieldList = array();
				foreach ($TCA[$table]['columns'] as $key => $_){
					$fieldList[] = array($key, $key);
				}
				$config['items'] = array_merge($config['items'], $fieldList);
			}
		}
		
		return $config;
	}

}

if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mfwc_shoolinfos/lib/class.tx_mfwcshoolinfos_flexform.php'])) {
	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mfwc_shoolinfos/lib/class.tx_mfwcshoolinfos_flexform.php']);
}


?>